<?php
namespace app\admin\controller;

use think\Controller;
use app\admin\model\Admin;

class Login extends Controller{
  
    public function index(){
        if(request()->isPost()){
            $admin = new Admin();
            $data = input('post.');
            $num = $admin->login($data);
            if($num == 3){
                $this->success('信息正确，正在为您跳转...','index/index');
            }elseif($num == 4){
                $this->error('验证码错误');
            }elseif($num == 2){
                $this->error('密码错误');
            }else{
                $this->error('用户名错误');
            }
        }
        return $this->fetch();
    }
  
  	public function logout(){
      
    	session('ADMIN_USERNAME', null);
        session('ADMIN_ID', null);
      	$this->success('退出成功!', 'admin/login/index');
    }
}

